﻿using System.ComponentModel;
using System.Xml.Serialization;

namespace uTILLIty.Rave.Core.StorageAdapter
{
	/// <summary>
	/// Represents an attribute name/value pair of an active-directory/LDAP entry
	/// </summary>
	public class ActiveDirectoryAttribute
	{
		/// <summary>
		/// Creates a default instance
		/// </summary>
		public ActiveDirectoryAttribute()
		{
			Type = ActiveDirectoryAttributeValueType.String;
		}

		/// <summary>
		/// Creates a full instance
		/// </summary>
		public ActiveDirectoryAttribute(string name, string value, ActiveDirectoryAttributeValueType type)
		{
			Name = name;
			Value = value;
			Type = type;
		}

		/// <summary>
		/// The attribute-name as per LDAP definition
		/// </summary>
		[XmlAttribute("name")]
		public string Name { get; set; }

		/// <summary>
		/// The type the <see cref="Value"/> is to be converted to
		/// </summary>
		[XmlAttribute("type"), DefaultValue(ActiveDirectoryAttributeValueType.String)]
		public ActiveDirectoryAttributeValueType Type { get; set; }

		/// <summary>
		/// The actual value of the <see cref="Name">attribute</see>
		/// </summary>
		[XmlText]
		public string Value { get; set; }
	}
}